package com.example.compress;

import android.graphics.Bitmap;

/***
 * @author zhudaihao
 * @time 2021/12/30
 * @data 图片压缩
 */
public class CompressImage {

    private CompressImage() {
    }

    private static CompressImage compressImage;

    public static CompressImage getInstance() {
        if (compressImage == null) {
            synchronized (CompressImage.class) {
                if (compressImage == null) {
                    compressImage = new CompressImage();
                    return compressImage;
                }
            }
        }
        return compressImage;
    }

    static {
        System.loadLibrary("native-lib");
    }


    /***
     * 压缩图片
     * @param bitmap 需要压缩的图片bitmap
     * @param q 压缩品质 0-100 值越大图片清晰度越低
     * @param path 压缩后的图片保存路径
     */
    public native void nativeCompress(Bitmap bitmap, int q, String path);

}
